from apps.merchant.shop.baseViews import *
from apps.system.user.dao import UserDao

class ShopViewSet(BaseShopViewSet):
    def get_queryset(self):
        params = getRequestParams(self.request)
        _list = ShopDao().findAll().select_related('trade', 'user')
        if params.get('routerName') == 'shop':
            if BaseDao().findRoleByAccount(self.request.user).key == 'admin':
                _list = _list.filter(Q(types='1')|Q(types='0'))
            else:
                _list = _list.filter(types='1')
        if params.get('routerName') == 'supplier':
            _list = _list.filter(types='3')
        return _list

    